package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @author Hasee
 * @version 1.0
 * @description: TODO
 * @date 2023/2/17 16:39
 */
@RestController("管理端")
@RequestMapping("/admin/shop")
@Slf4j
@Api("营业相关接口")
public class ShopController {


    private static final String key = "shop_status";
    @Autowired
    private RedisTemplate redisTemplate;

   @PutMapping("/{status}")
    @ApiOperation("设置营业状态")
    public Result setStatus(@PathVariable Integer status){
       redisTemplate.opsForValue().set(key,status);
       return Result.success(status);
   }
    @GetMapping("/status")
    @ApiOperation("获取营业状态")
    public Result getStatus(){
        Integer status  = (Integer) redisTemplate.opsForValue().get(key);
        return Result.success(status);
    }
}
